package cn.yunhe.controller;

import cn.yunhe.service.GrandTypeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/DeleteGrandSonTypeServlet")
public class DeleteGrandSonTypeServlet  extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        int chtypeid=Integer.parseInt(request.getParameter("chtypeid"));
        request.setAttribute("chtypeid",chtypeid);
        int gid=Integer.parseInt(request.getParameter("gid"));
        System.out.println("所属子类"+chtypeid);
        GrandTypeService grandTypeService=new GrandTypeService();
        boolean flag = grandTypeService.deleteGrandSonType(gid);
        if(flag){
            request.getRequestDispatcher("ShowGrandSonServlet").forward(request,response);
        }else{
            response.sendRedirect("false.html");

        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
